<!--
 * @Description: 
 * @Author: charles
 * @Date: 2021-12-19 10:04:31
 * @LastEditors: 刘佳欢 2173558681@qq.com
 * @LastEditTime: 2025-09-28 08:45:50
-->
<!-- <template>
  <div>
    <el-button @click="backHandler">返回</el-button>
    学生详情
  </div>
</template>
<script>
export default {
  mounted() {
    let id = this.$route.query.id;
    alert(id);
  },
  methods:{
    backHandler(){
      this.$router.go(-1);
    }
  }
}
</script> -->

<template>
  <div>
    <el-button @click="backHandler">返回</el-button>
    <h3>学生详情</h3>
    <el-form :model="student" label-width="120px">
      <el-form-item label="ID">
        <el-input v-model="student.id" disabled></el-input>
      </el-form-item>
      <el-form-item label="学号">
        <el-input v-model="student.no" disabled></el-input>
      </el-form-item>
      <el-form-item label="姓名">
        <el-input v-model="student.name" disabled></el-input>
      </el-form-item>
      <el-form-item label="性别">
        <el-input v-model="student.gender" disabled></el-input>
      </el-form-item>
      <el-form-item label="电话">
        <el-input v-model="student.telephone" disabled></el-input>
      </el-form-item>
      <el-form-item label="生日">
        <el-input v-model="student.birth" disabled></el-input>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  data() {
    return {
      student: {},
    };
  },
  mounted() {
    const id = this.$route.query.id;
    this.getStudentDetails(id);
  },
  methods: {
    getStudentDetails(id) {
      // 根据 ID 从模拟数据中获取学生详情
      const studentData = {
        1: {
          id: 1,
          no: "2308300046",
          name: "刘佳欢",
          gender: "女",
          telephone: "13800138001",
          birth: "2000-01-01",
        },
        2: {
          id: 2,
          no: "2308300002",
          name: "宋佳馨",
          gender: "女",
          telephone: "13800138002",
          birth: "2000-02-02",
        },
        3: {
          id: 3,
          no: "2308300029",
          name: "崔凤瑶",
          gender: "女",
          telephone: "13800138003",
          birth: "2000-03-03",
        },
      };
      this.student = studentData[id] || {};
    },
    backHandler() {
      this.$router.go(-1);
    },
  },
};
</script>